const isProduction = process.env.NODE_ENV === 'production';
const CompressionWebpackPlugin = require('compression-webpack-plugin');

module.exports = {
  chainWebpack: config => {
    config
        .entry('index')
        .add('babel-polyfill')
  },
  publicPath: '/', //isProduction ? './' : '/'
  assetsDir: 'assets',
  lintOnSave: isProduction ? false : true,
  productionSourceMap: false,
  configureWebpack: () => {
    if (isProduction) {
      return {
        plugins: [
          new CompressionWebpackPlugin({
            filename: '[path].gz[query]',
            algorithm: 'gzip',
            test: /\.(js|css|json|txt|html|ico|svg)(\?.*)?$/i,
            threshold: 2048,
            minRatio: 0.8
          })
        ]
      }
    }
  },
  devServer:{
    proxy : {
      "/api":{ 
        target: 'http://118.24.31.25:8889', 
        changeOrigin: true,
        pathRewrite:{
        '^/api':''
        }
      }
    } 
  }
  
}
